package xyz.jangle.base;

import java.util.Iterator;
import java.util.TreeSet;
/**
 * TreeSet demo
 * 树集
 * @author Administrator
 *
 */
public class Example13_8 {

	public static void main(String[] args) {
		TreeSet<Student2> treeSet = new TreeSet<Student2>();
		Student2 s1 = new Student2("A", 60);
		Student2 s2 = new Student2("B", 80);
		Student2 s3 = new Student2("C", 70);
		Student2 s4 = new Student2("D", 80);
		treeSet.add(s1);
		treeSet.add(s2);
		treeSet.add(s3);
		treeSet.add(s4);
		Iterator<Student2> iterator = treeSet.iterator();
		while(iterator.hasNext()) {
			Student2 next = iterator.next();
			System.out.println(next.getName()+","+next.getEnglish());
		}
		System.out.println("----------");
		for(Student2 s:treeSet) {
			System.out.println(s.getName()+","+s.getEnglish());
		}

	}

}


